package monopoly;

public class Utility extends Property {
	
	
	public Utility()
	{
		super();
	}
	
	public Utility(double price, String description)
	{
		super(price, "images/tableIcon/util.gif", description);
	}

	public double getRent(GameState gameState, int rentMultiplier)
	{
		int count;
		double rent;
		Player owner = super.getOwner();
		count = owner.getUtilityCount();
		double total = (double) gameState.getDie1().getFaceValue() + gameState.getDie2().getFaceValue();
		
		switch (count)
		{
		case 1:	rent = total * 4.0; break;
		case 2: rent =  total * 10.0; break;
		default: rent = 0.0;
		}
		
		if (rentMultiplier != 0) rent *= rentMultiplier;
		return rent;
	}
	
	
	public void purchase(Player player)
	{
			player.adjustBalance(0-super.getPrice());
			super.setOwner(player);
			player.buyUtility(this);
	}
}
